from info import build_manager

manager = build_manager('develop')

from info.models import *
from info.utils.encript import *
import uuid

if __name__ == '__main__':
    admin_s = []
    for i in range(10):
        tel = '0' + ('%s' % i) * 9
        admin_s.append(Admin(tel=tel,password=md5(tel)))
    db.session.add_all(admin_s)
    db.session.commit()

    user_s = []
    for i in range(10):
        tel = '1' + ('%s' % i) * 10
        image_url = 'static/user_image/default.png'
        uid = uuid.uuid4().__str__()
        user_s.append(User(
            tel=tel,
            password=md5(tel),
            image_url=image_url,
            uid=uid,
        ))
    db.session.add_all(user_s)
    db.session.commit()

    category_s = []
    for i in range(1,6):
        kind = '种类%s' % i
        category_s.append(Category(category=kind))
    db.session.add_all(category_s)
    db.session.commit()

    news_s = []
    for i in range(100):
        categoryid = category_s[i % len(category_s)].id
        userid = user_s[i % len(user_s)].id
        title = '新闻%s属于种类%s' % (i,categoryid)
        summary = title + ('摘要_' * 5)
        image_url = 'static/news_image/default.png'
        body = '正文'*400
        status = 1
        news_s.append(News(
            category_id=categoryid,
            user_id=userid,
            title = title,
            summary = summary,
            image_url = image_url,
            body = body,
            status = status,
        ))
    db.session.add_all(news_s)
    db.session.commit()



